/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.xtd.view.admin;

import com.xtd.facade.admin.SystemPropertyFacade;
import com.xtd.model.admin.SystemProperty;
import com.xtd.view.AbstractManager;
import com.xtd.view.ApplicationBean;
import java.util.ArrayList;
import java.util.List;
import javax.ejb.EJB;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.SessionScoped;
import javax.faces.event.ActionEvent;

/**
 *
 * @author Lu Yuanbin
 */
@ManagedBean
@SessionScoped
public class SystemPropertyManager extends AbstractManager {

    @EJB
    SystemPropertyFacade systemPropertyFacade;
    private List<SystemProperty> systemPropertyList;
    private SystemProperty selectedProperty;
    private List inclinationItems;
    private List sourceItems;
    private List emphasisItems;
    private List competitorItems;
    @ManagedProperty( value="#{applicationBean}")
    private ApplicationBean applicationBean;

    /** Creates a new instance of SystemPropertyManager */
    public SystemPropertyManager() {
    }

    /**
     * @return the systemPropertyList
     */
    public List<SystemProperty> getSystemPropertyList() {
        if (systemPropertyList == null) {
            systemPropertyList = new ArrayList();
            systemPropertyList.addAll(systemPropertyFacade.findAll());
        }
        return systemPropertyList;
    }

    /**
     * @param systemPropertyList the systemPropertyList to set
     */
    public void setSystemPropertyList(List<SystemProperty> systemPropertyList) {

        this.systemPropertyList = systemPropertyList;
    }

    /**
     * @return the selectedProperty
     */
    public SystemProperty getSelectedProperty() {

        return selectedProperty;
    }

    /**
     * @param selectedProperty the selectedProperty to set
     */
    public void setSelectedProperty(SystemProperty selectedProperty) {

        this.selectedProperty = selectedProperty;
    }

    /**
     * @return the inclinationItems
     */
    public List getInclinationItems() {

        return inclinationItems;
    }

    /**
     * @param inclinationItems the inclinationItems to set
     */
    public void setInclinationItems(List inclinationItems) {
        this.inclinationItems = inclinationItems;
    }

    /**
     * @return the sourceItems
     */
    public List getSourceItems() {

        return sourceItems;
    }

    /**
     * @param sourceItems the sourceItems to set
     */
    public void setSourceItems(List sourceItems) {
        this.sourceItems = sourceItems;
    }

    /**
     * @return the EmphasisItems
     */
    public List getEmphasisItems() {

        return emphasisItems;
    }

    /**
     * @param EmphasisItems the EmphasisItems to set
     */
    public void setEmphasisItems(List emphasisItems) {
        this.emphasisItems = emphasisItems;
    }

    /**
     * @return the competitorItems
     */
    public List getCompetitorItems() {

        return competitorItems;
    }

    /**
     * @param competitorItems the competitorItems to set
     */
    public void setCompetitorItems(List competitorItems) {
        this.competitorItems = competitorItems;
    }

    public void save(ActionEvent actionEvent) {
        systemPropertyFacade.edit(selectedProperty);
        applicationBean.initSelectItem();
        addMessage("保存成功", null, FacesMessage.SEVERITY_INFO);
    }

    /**
     * @return the applicationBean
     */
    public ApplicationBean getApplicationBean() {
        return applicationBean;
    }

    /**
     * @param applicationBean the applicationBean to set
     */
    public void setApplicationBean(ApplicationBean applicationBean) {
        this.applicationBean = applicationBean;
    }
}
